Skip to content

Fix non-deterministic encoding of syntax contexts - #161450

Open
aerooneqq wants to merge 1 commit into
rust-lang:mainfrom
aerooneqq:syntax-ctxt-non-deterministic-encoding
Open

aerooneqq wants to merge 1 commit into
rust-lang:mainfrom
aerooneqq:syntax-ctxt-non-deterministic-encoding

Conversation

@aerooneqq

@aerooneqq aerooneqq commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

View all comments

Reiteration of #157409. Explanation can be found in comment for encoding_indices and in the issue.

Fixes #129094. Blocked by #161353.

r? @petrochenkov

No llms used.

@rustbot rustbot added A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 21, 2026
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 21, 2026
@rust-log-analyzer

This comment has been minimized.

@aerooneqq
aerooneqq force-pushed the syntax-ctxt-non-deterministic-encoding branch from b07d315 to 3f750ec Compare August 21, 2026 10:33
@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@aerooneqq
aerooneqq force-pushed the syntax-ctxt-non-deterministic-encoding branch from a34d24f to 3868148 Compare September 2, 2026 08:27
@rustbot

This comment has been minimized.

Comment thread compiler/rustc_span/src/hygiene.rs Outdated
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 3, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 3, 2026
…ing, r=<try>

Fix non-deterministic encoding of syntax contexts
@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 3, 2026
@rust-bors

rust-bors Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 7e01adf (7e01adfdd3209974b2d32d2eb35d4173deaa540b)
Base parent: 4fcf397 (4fcf39725a9c99bd495d8c73af83628a256ff9a9)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (7e01adf): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.6% [0.1%, 1.9%] 72
Regressions ❌
(secondary)
0.6% [0.1%, 1.7%] 50
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.6% [0.1%, 1.9%] 72

Max RSS (memory usage)

Results (primary 1.0%, secondary -1.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.0% [1.0%, 1.0%] 1
Regressions ❌
(secondary)
3.7% [2.6%, 4.9%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.7% [-4.6%, -1.4%] 5
All ❌✅ (primary) 1.0% [1.0%, 1.0%] 1

Cycles

Results (primary -0.2%, secondary 4.5%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.3% [2.3%, 2.3%] 1
Regressions ❌
(secondary)
4.5% [4.5%, 4.5%] 1
Improvements ✅
(primary)
-2.7% [-2.7%, -2.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.2% [-2.7%, 2.3%] 2

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 476.065s -> 474.462s (-0.34%)
Artifact size: 401.18 MiB -> 401.32 MiB (0.03%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Sep 3, 2026
@petrochenkov petrochenkov added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 3, 2026
@aerooneqq
aerooneqq force-pushed the syntax-ctxt-non-deterministic-encoding branch from 3868148 to 4846400 Compare September 7, 2026 09:48
rust-bors Bot pushed a commit that referenced this pull request Sep 13, 2026
…ing, r=<try>

Fix non-deterministic encoding of syntax contexts
@petrochenkov petrochenkov removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 13, 2026
@rust-bors

rust-bors Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 39a7792 (39a77924d69cd79ad293cefa28ac22d76ff9fa69)
Base parent: 98fd715 (98fd715edd3a0a5aa8f2041d7e20a3143b0fc0d3)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (39a7792): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.3% [0.1%, 0.5%] 29
Regressions ❌
(secondary)
0.3% [0.1%, 0.5%] 18
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.1%, 0.5%] 29

Max RSS (memory usage)

Results (primary -0.6%, secondary -0.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.5% [3.0%, 4.2%] 3
Improvements ✅
(primary)
-0.6% [-0.7%, -0.5%] 2
Improvements ✅
(secondary)
-4.7% [-8.2%, -2.7%] 3
All ❌✅ (primary) -0.6% [-0.7%, -0.5%] 2

Cycles

Results (secondary -5.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.1% [3.1%, 3.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-9.2% [-15.3%, -3.1%] 2
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.0%, secondary 0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.1%] 26
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.1%] 26

Bootstrap: 492.1s -> 494.686s (0.53%)
Artifact size: 406.87 MiB -> 406.94 MiB (0.02%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 13, 2026
Comment thread compiler/rustc_span/src/hygiene.rs Outdated
Comment thread compiler/rustc_span/src/hygiene.rs
@petrochenkov petrochenkov added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 13, 2026
Comment thread compiler/rustc_span/src/hygiene.rs
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 14, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 14, 2026
…ing, r=<try>

Fix non-deterministic encoding of syntax contexts
@rust-bors

rust-bors Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 75e938b (75e938be4f6790138aa93ac7dcb1baf800c9fc3b)
Base parent: b722b55 (b722b5567eab6912db411110a2dcd7995b2d72cf)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (75e938b): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never rustc-perf
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.1% [0.1%, 0.1%] 1
Regressions ❌
(secondary)
0.4% [0.3%, 0.5%] 4
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 1
Improvements ✅
(secondary)
-0.2% [-0.3%, -0.2%] 4
All ❌✅ (primary) -0.0% [-0.2%, 0.1%] 2

Max RSS (memory usage)

Results (primary -1.2%, secondary -1.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.9% [3.0%, 4.9%] 3
Improvements ✅
(primary)
-1.2% [-1.8%, -0.6%] 2
Improvements ✅
(secondary)
-3.9% [-8.1%, -1.6%] 5
All ❌✅ (primary) -1.2% [-1.8%, -0.6%] 2

Cycles

Results (primary -1.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.6% [0.6%, 0.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.1% [-3.1%, -3.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.2% [-3.1%, 0.6%] 2

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 498.957s -> 493.438s (-1.11%)
Artifact size: 406.94 MiB -> 406.96 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 14, 2026
@aerooneqq
aerooneqq force-pushed the syntax-ctxt-non-deterministic-encoding branch from 658483a to e6d2012 Compare September 15, 2026 11:45
@aerooneqq
aerooneqq force-pushed the syntax-ctxt-non-deterministic-encoding branch from e6d2012 to a26d7b6 Compare September 15, 2026 11:46
@aerooneqq

Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 15, 2026

impl Default for HygieneEncodeContext {
fn default() -> HygieneEncodeContext {
Self {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Self {
HygieneEncodeContext {

serialized_expns: Default::default(),
latest_expns: Default::default(),
// Zero is taken by root syntax context.
encoding_indices: FxHashMap::from_iter(std::iter::once((SyntaxContext::root(), 0))),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
encoding_indices: FxHashMap::from_iter(std::iter::once((SyntaxContext::root(), 0))),
encoding_indices: FxHashMap::from_iter(iter::once((SyntaxContext::root(), 0))),

@petrochenkov

Copy link
Copy Markdown
Contributor

r=me with the nits addressed.
@bors delegate+
@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 15, 2026
@rust-bors

rust-bors Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

✌️ @aerooneqq, you can now approve this pull request!

If @petrochenkov told you to "r=me" after making some further change, then please make that change and post @bors r=petrochenkov.

View changes since this delegation.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 15, 2026
@rustbot

rustbot commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) A-run-make Area: port run-make Makefiles to rmake.rs perf-regression Performance regression. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

derives: parallel compiler makes builds irreproducible

5 participants